$(function(){
    var _txtpresentation_val = "", editor;
	
    /* JQUERY_EXTEND */
    $.extend({ 		
		
        // PRESENTATION
        initPresentation : function(){
            editorTXT();	
        },
        savePresentation : function(txtpresentacion){
            if(_txtpresentation_val == txtpresentacion) return false;

            $("#bnt-save-presentation").attr('disabled','-1');
            $.post("./?ws=Presentation&act=SaveLesCSME", {
                _txtpresentation: txtpresentacion, 
                cache:new Date().getTime()
            }, function(data){
                if($.trim(data)!=""){
                    _txtpresentation_val = txtpresentacion;
                    alert("Donn\u00E9es sauvegarder avec succ\u00E8s.");
                    $("#bnt-save-presentation").removeAttr('disabled');
                }
                else{
                    $("#bnt-save-presentation").removeAttr('disabled');
                }
            });
        }
    // END PRESENTATION

    });
    /* END JQUERY_EXTEND */

    function editorTXT(){
        new nicEditor({
            buttonList: [
            'bold','italic','underline','strikethrough','left','justify','link','unlink','removeformat'
            ],
            iconsPath: './Resouces/js/wysiwyg/nicEditorIcons.gif',
            maxHeight: 300
        }).panelInstance('txtpresentation',{
            hasPanel : true
        });

        editor = nicEditors.findEditor('txtpresentation');
    }
	
    // Save Presentation
    $("#bnt-save-presentation").click(function(){
        $.savePresentation( editor.getContent() );
    });
		
    //Initializing
    $.initPresentation();

});
